package com.hjh.pro2.util;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class FileUtils {

    private FileUtils(){}

    /**
     * 把内容写到文件中
     * @param filePath
     * @param content
     */
    public static void write2File(String filePath,String content){
        filePath = StringUtils.trimToEmpty(filePath);
        OutputStream out= null;
        try {
            out=new FileOutputStream(filePath);
            IOUtils.write(content,out,"UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(out != null){
                IOUtils.closeQuietly(out);
            }
        }
    }

}
